<?php

namespace App\Services;

use Validator;

class PhoneServer
{
    //自定义验证器
    public function projectDataValidator($params){
        //定义规则
        $rules = [
            'phone' => 'required',   //手机号
        ];
        //重新编辑错误信息
        $messages = [
            'phone.required|max:11|/^1[3-9]{1}[0-9]{9}$/' => '请输入手机号|手机号最多11位|手机号码格式不正确',
        ];
        //验证
        $validator = Validator::make($params, $rules, $messages);
        //验证失败
        if($validator->fails()){
            return $validator->errors()->first();   //返回错误信息
        }
    }
}
